package 算法;

import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author coderFu
 * @create 2022/3/14
 */
public class Combine {

    public static void main(String[] args) {



    }

    public ListNode MergeList(ListNode l1, ListNode l2) {
        // write code here
        ArrayList<Integer> list = new ArrayList<>();

        while(l1 != null){

            list.add(l1.val);
            l1 = l1.next;
        }

        while(l2 != null){
            list.add(l2.val);
            l2 = l2.next;
        }
        list.sort(Comparator.comparing(Integer::intValue));

        ListNode root = new ListNode(list.get(0));
        ListNode result = root;
        for (int i=1; i<list.size(); i++){
            root.next = new ListNode(list.get(i));
            root = root.next;
        }

        return result;

    }
}




   class ListNode {
   int val;
    ListNode next = null;
    public ListNode(int val) {
      this.val = val;
    }
  }
